FreeBSD Part 2: Installation

I do not want to go into too much details of the installation process. It is pretty standard, create a boot medium, e.g. on a USB stick:

$ dd if=~/Downloads/FreeBSD-$VERSION.img of=/dev/sdc bs=4M

But a word of advice here is that if you have difficulties booting, or encounter errors during installation, it is well worth it to think about a BIOS update. Usually, the manufacturer of your PC or motherboard will supply ISOs, which you can copy onto a USB stick just like the FreeBSD install medium. Those then provide an update utility, either by booting into it, or via menu entries in the BIOS. In my experience it is worth running an up to date BIOS in any case.

I assume, that like me you have deselected everything during installation, giving you a very minimal system indeed.

After Installation

FreeBSD delivers a very minimal system by default. You will most likely have a root-user and one or more regular users created during installation. You will also have networking, but that is about it. Your first boot will end in a shell, from which a desktop system has to be set up manually. Start by adding all users that should have a desktop to the groups wheel and operator and video, if you haven’t done so already during their creation.

Installing additional software is easy on FreeBSD, as long as you have internet. I start with my standard console tools:

# pkg install vim tmux openvpn password-store [...]

Graphical User Interface

Although I do a lot of work on the console, a graphical user interface is still the way to go for a desktop or laptop computer. I prefer a simple tiling window manager like i3 or sway, but the following steps apply in any case.

First, you need to take care of the video driver. To load the kernel module, modify your /etc/rc.conf like so:

[...]
kld_list="${kld_list} i915kms"
[...]

Replace i915kms with the appropriate driver for your video card. Then install your desktop environment and a display manager. Don’t forget to also include a terminal emulator:

# pkg install i3 i3bar i3status xdm rxvt-unicode

and enable the display manager in the /etc/rc.conf:

[...]
xdm_enable="YES"
[...]

in my case with the Intel video driver and a Haswell based integrated GPU, I also needed to put the following into /usr/local/etc/X11/xorg.conf.d/driver-modesetting.conf:

Section "Device"
        Identifier  "Intel Graphics"
        Driver      "modesetting"
        Option      "AccelMethod" "none"
EndSection

Now you need to tell xdm, what window manager you would like to have after login. To do that, add the following to your ~/.xinitrc:

export LC_ALL=en_US.UTF-8
i3

Reboot and you should be greeted by xdm asking you for your login.

Customize

xdm is pretty ugly by default IMO, but we can easily improve on that. To get a very simple login screen, just black with simple prompts, put this in /usr/local/etc/X11/xdm/Xresources:

xlogin.Login.greeting:
xlogin.Login.unsecureGreeting:
xlogin.Login.fail:                   Fail.
xlogin.Login.changePasswdMessage:    Change Password.
xlogin.Login.namePrompt:             Username:
xlogin.Login.passwdPrompt:           Password:
xlogin.Login.echoPasswd:             true
xlogin.Login.background:             black
xlogin.Login.foreground:             #dddddd
xlogin.Login.failColor:              #cccccc
xlogin.Login.inpColor:               black
xlogin.Login.promptColor:            #aaaaaa
xlogin.Login.face:                   courier:size=13:style=Bold
xlogin.Login.failFace:               courier:size=13:style=Bold
xlogin.Login.promptFace:             courier:size=13:style=Normal
xlogin.Login.greetFace:              courier:size=13:style=Normal
xlogin.Login.width:                  400

Then execute (as root):

# xrdb /usr/local/etc/X11/xdm/Xresources

Sound

To get sound, you need a driver ofcourse. YMMV, but in my case, I needed to load the snd_hda driver by adding to my /etc/rc.conf:

[...]
kld_list="${kld_list} snd_hda"
[...]

CPU Frequency Scaling

For power saving, which is especially important on a laptop, you need to enable powerd and load the respective kernel modules in /etc/rc.conf:

[...]
kld_list="${kld_list} coretemp cpuctl"

powerd_enable="YES"
[...]
2021-05-04 22:07